set scheme s1color
graph set window fontface "Arial Narrow"
grstyle init
grstyle set plain, horizontal grid compact
grstyle set color gs0 gs0 gs0
grstyle set ci
grstyle color tick gs8
grstyle color tick_label gs8
grstyle color legend gs15
grstyle clockdir legend_position 4
grstyle numstyle legend_cols 1
grstyle linestyle legend none

cd "C:\Users\WeisstaD\Dropbox (Dept of Pol Science)\Symbolic Class\data"

********************************************************************************
**# ANALYSIS *******************************************************************
********************************************************************************

*----------------------------------------------------------------------------------*
**# Figure 1: Effects of candidate attributes on party leader choice probability ***
*----------------------------------------------------------------------------------*

use SYMBREP_FINAL, clear
reg CHOICE_DV i.ATTR_GENDER i.ATTR_EDUCATION i.ATTR_ORIGIN i.ATTR_ECONPOS i.ATTR_CULTPOS  i.ATTR_CULTCON, vce(cluster record)
	outreg using Regression_output, replace starlev(10 5 1 0.1) sigsymbol(+,*,**,***) bdec(2) starloc(1) se basefont(fs9) nosubstat summstat(r2 \ N)
	margins, at(ATTR_GENDER=(1 2)) at(ATTR_EDUCATION=(1 2)) at(ATTR_ORIGIN=(1 2 3)) at(ATTR_ECONPOS=(1 2)) at(ATTR_CULTPOS=(1 2)) at(ATTR_CULTCON=(1 2 3)) post

coefplot, xline(0.5, lcol(gs7)) msize(*0.8) ciopts(recast(rcap) lwidth(*1.1)) headings(1._at = "{bf:Gender}" 3._at = "{bf:Education}" ///
	5._at = "{bf:Class origin}"	8._at = "{bf:Position economic dimension}" 10._at = "{bf:Position cultural dimension}" 12._at = "{bf:Cultural consumption}", labcol(gs2)) ///
	coeflab(1._at = "Male candidate" 2._at = "Female candidate" 3._at = "Candidate has a university degree" 4._at = "Candidate has a vocational degree" ///
	5._at = "Candidate from wealthy family" 6._at = "Candidate from teacher family" ///
	7._at = "Candidate from working-class family" 8._at = "Candidate left-wing on economic issues" ///
	9._at = "Candidate right-wing on economic issues" 10._at = "Candidate left-wing on cultural issues" ///
	11._at = "Candidate right-wing on cultural issues"  12._at = "Candidate enjoys classical music/glass of wine" ///
	13._at = "Candidate enjoys meeting friends" 14._at = "Candidate enjoys drinking beer in favourite pub", labcol(gs2))	///
	xtitle("Party leader choice probability (marginal means)", col(gs6) size(*0.75)) ///
	ytitle("", col(gs6) size(*0.8)) xlab(,format(%3.2f)) scale(*1.35) level(95) xsize(6)

*----------------------------------------------------------------*
**# Figure 2: Effects of cultural consumption by voters' party ***
*----------------------------------------------------------------*

use SYMBREP_FINAL, clear
cap postclose results_party
postfile results_party ATTR_CULTCON b LB95 UB95 y str50 ylab using results_party, replace

foreach cultcon of numlist 1 3 {
reg CHOICE_DV i.ATTR_GENDER i.ATTR_EDUCATION i.ATTR_ECONPOS i.ATTR_CULTPOS i.ATTR_ORIGIN i.ATTR_CULTCON, vce(cluster record)	
	margins, at(ATTR_CULTCON=(`cultcon'))
		post results_party (`cultcon') (r(table)[1,1]) (r(table)[5,1]) (r(table)[6,1]) (1.5) ("Overall")
reg CHOICE_DV i.ATTR_GENDER##i.PARTY i.ATTR_EDUCATION##i.PARTY i.ATTR_ECONPOS##i.PARTY i.ATTR_CULTPOS##i.PARTY i.ATTR_ORIGIN##i.PARTY i.ATTR_CULTCON##i.PARTY, vce(cluster record)
	if `cultcon' == 3 	outreg using Regression_output, merge replace starlev(10 5 1 0.1) sigsymbol(+,*,**,***) bdec(2) starloc(1) se basefont(fs9) nosubstat summstat(r2 \ N)
	margins, at(ATTR_CULTCON=(`cultcon') PARTY=(1))
		post results_party (`cultcon') (r(table)[1,1]) (r(table)[5,1]) (r(table)[6,1]) (4) ("Radical right (SVP)")
	margins, at(ATTR_CULTCON=(`cultcon') PARTY=(3))
		post results_party (`cultcon') (r(table)[1,1]) (r(table)[5,1]) (r(table)[6,1]) (5) ("Center-right / liberals (FDP)")
	margins, at(ATTR_CULTCON=(`cultcon') PARTY=(5))
		post results_party (`cultcon') (r(table)[1,1]) (r(table)[5,1]) (r(table)[6,1]) (6) ("Center-right / Christian democrats (Mitte)")
	margins, at(ATTR_CULTCON=(`cultcon') PARTY=(2))
		post results_party (`cultcon') (r(table)[1,1]) (r(table)[5,1]) (r(table)[6,1]) (7) ("Center-left / social democrats (SP)")
	margins, at(ATTR_CULTCON=(`cultcon') PARTY=(6))
		post results_party (`cultcon') (r(table)[1,1]) (r(table)[5,1]) (r(table)[6,1]) (8) ("Green-liberals (GLP)")
	margins, at(ATTR_CULTCON=(`cultcon') PARTY=(4))
		post results_party (`cultcon') (r(table)[1,1]) (r(table)[5,1]) (r(table)[6,1]) (9) ("Greens (GPS)")
}		
	margins rb1.PARTY, at(ATTR_CULTCON=3)
		
postclose results_party
use results_party, clear
	replace y = -y
	lab def ATTR_CULTCON 1 `""Candidate enjoys listening to" "classical music with a glass of wine" "(upper-class cultural consumption)""' ///
		 3 `""Candidate enjoys going to" "drink a beer in favourite pub" "(working-class cultural consumption)""'
	lab val ATTR_CULTCON ATTR_CULTCON
twoway scatter y b, subtitle(,size(*0.8)) || rcap LB95 UB95 y, horizontal by(ATTR_CULTCON, note("") legend(off) scale(*1.95) imargin(*20)) ///
	yscale(range(0 -9.5)) xline(0.5, lcol(gs6) lpattern(solid)) ///
	ytitle("", col(gs6) size(*0.8)) ylab(-1.5 "Overall (all voters)" -4 "Radical right (SVP) voters" -5 "Center-right / liberals (FDP) voters" ///
	-6 "Center-right / Christian dem. (Mitte) voters" -7 "Center-left / social democratic (SP) voters" ///
	-8 "Green-liberal (GLP) voters" -9 "Green (GPS) voters", labcol(gs0)) xlab(, labcol(gs6) format(%3.2f)) ///
	xtitle("                                                                     Party leader choice probability (marginal means)", col(gs6) size(*0.7)) ysize(2.4)

*----------------------------------------------------------------------------*
**# Figure 3: Effects of beer attribute, by party and socioeconomic status ***
*----------------------------------------------------------------------------*
	
use SYMBREP_FINAL, clear
cap postclose results_party_SES
postfile results_party_SES str20 SES SESval b LB95 UB95 y str50 ylab using results_party_SES, replace

gen NONTERTIARY2 = -(TERTIARY2-1)
gen LOWINC = (inrange(HINC10, 1, 5)) if !mi(HINC10)
gen WORKER = (inlist(OESCH, 5)) if !mi(OESCH)
gen LOWSSS = (inrange(SSS, 0, 5)) if !mi(SSS)

foreach nontert of numlist 0 1 {
preserve
keep if NONTERTIARY2 == `nontert'
local SES = "NONTERTIARY2"
reg CHOICE_DV i.ATTR_GENDER i.ATTR_EDUCATION i.ATTR_ECONPOS i.ATTR_CULTPOS i.ATTR_ORIGIN i.ATTR_CULTCON, vce(cluster record)
	margins, at(ATTR_CULTCON=(3))
		post results_party_SES ("`SES'") (`nontert') (r(table)[1,1]) (r(table)[5,1]) (r(table)[6,1]) (1.5) ("Overall")
reg CHOICE_DV i.ATTR_GENDER##i.PARTY i.ATTR_EDUCATION##i.PARTY i.ATTR_ECONPOS##i.PARTY i.ATTR_CULTPOS##i.PARTY i.ATTR_ORIGIN##i.PARTY i.ATTR_CULTCON##i.PARTY, vce(cluster record)
	margins, at(ATTR_CULTCON=(3) PARTY=(1))
		post results_party_SES ("`SES'") (`nontert') (r(table)[1,1]) (r(table)[5,1]) (r(table)[6,1]) (4) ("Radical right (SVP)")
	margins, at(ATTR_CULTCON=(3) PARTY=(3))
		post results_party_SES ("`SES'") (`nontert') (r(table)[1,1]) (r(table)[5,1]) (r(table)[6,1]) (5) ("Center-right / liberals (FDP)")
	margins, at(ATTR_CULTCON=(3) PARTY=(5))
		post results_party_SES ("`SES'") (`nontert') (r(table)[1,1]) (r(table)[5,1]) (r(table)[6,1]) (6) ("Center-right / Christian democrats (Mitte)")
	margins, at(ATTR_CULTCON=(3) PARTY=(2))
		post results_party_SES ("`SES'") (`nontert') (r(table)[1,1]) (r(table)[5,1]) (r(table)[6,1]) (7) ("Center-left / social democrats (SP)")
	margins, at(ATTR_CULTCON=(3) PARTY=(6))
		post results_party_SES ("`SES'") (`nontert') (r(table)[1,1]) (r(table)[5,1]) (r(table)[6,1]) (8) ("Green-liberals (GLP)")
	margins, at(ATTR_CULTCON=(3) PARTY=(4))
		post results_party_SES ("`SES'") (`nontert') (r(table)[1,1]) (r(table)[5,1]) (r(table)[6,1]) (9) ("Greens (GPS)") 
restore
}
foreach lowinc of numlist 0 1 {
preserve
keep if LOWINC == `lowinc'
local SES = "LOWINC"
reg CHOICE_DV i.ATTR_GENDER i.ATTR_EDUCATION i.ATTR_ECONPOS i.ATTR_CULTPOS i.ATTR_ORIGIN i.ATTR_CULTCON, vce(cluster record)
	margins, at(ATTR_CULTCON=(3))
		post results_party_SES ("`SES'") (`lowinc') (r(table)[1,1]) (r(table)[5,1]) (r(table)[6,1]) (1.5) ("Overall")
reg CHOICE_DV i.ATTR_GENDER##i.PARTY i.ATTR_EDUCATION##i.PARTY i.ATTR_ECONPOS##i.PARTY i.ATTR_CULTPOS##i.PARTY i.ATTR_ORIGIN##i.PARTY i.ATTR_CULTCON##i.PARTY, vce(cluster record)
	margins, at(ATTR_CULTCON=(3) PARTY=(1))
		post results_party_SES ("`SES'") (`lowinc') (r(table)[1,1]) (r(table)[5,1]) (r(table)[6,1]) (4) ("Radical right (SVP)")
	margins, at(ATTR_CULTCON=(3) PARTY=(3))
		post results_party_SES ("`SES'") (`lowinc') (r(table)[1,1]) (r(table)[5,1]) (r(table)[6,1]) (5) ("Center-right / liberals (FDP)")
	margins, at(ATTR_CULTCON=(3) PARTY=(5))
		post results_party_SES ("`SES'") (`lowinc') (r(table)[1,1]) (r(table)[5,1]) (r(table)[6,1]) (6) ("Center-right / Christian democrats (Mitte)")
	margins, at(ATTR_CULTCON=(3) PARTY=(2))
		post results_party_SES ("`SES'") (`lowinc') (r(table)[1,1]) (r(table)[5,1]) (r(table)[6,1]) (7) ("Center-left / social democrats (SP)")
	margins, at(ATTR_CULTCON=(3) PARTY=(6))
		post results_party_SES ("`SES'") (`lowinc') (r(table)[1,1]) (r(table)[5,1]) (r(table)[6,1]) (8) ("Green-liberals (GLP)")
	margins, at(ATTR_CULTCON=(3) PARTY=(4))
		post results_party_SES ("`SES'") (`lowinc') (r(table)[1,1]) (r(table)[5,1]) (r(table)[6,1]) (9) ("Greens (GPS)") 
restore
}
foreach wrker of numlist 0 1 {
preserve
keep if WORKER == `wrker'
local SES = "WORKER"
reg CHOICE_DV i.ATTR_GENDER i.ATTR_EDUCATION i.ATTR_ECONPOS i.ATTR_CULTPOS i.ATTR_ORIGIN i.ATTR_CULTCON, vce(cluster record)
	margins, at(ATTR_CULTCON=(3))
		post results_party_SES ("`SES'") (`wrker') (r(table)[1,1]) (r(table)[5,1]) (r(table)[6,1]) (1.5) ("Overall")
reg CHOICE_DV i.ATTR_GENDER##i.PARTY i.ATTR_EDUCATION##i.PARTY i.ATTR_ECONPOS##i.PARTY i.ATTR_CULTPOS##i.PARTY i.ATTR_ORIGIN##i.PARTY i.ATTR_CULTCON##i.PARTY, vce(cluster record)
	margins, at(ATTR_CULTCON=(3) PARTY=(1))
		post results_party_SES ("`SES'") (`wrker') (r(table)[1,1]) (r(table)[5,1]) (r(table)[6,1]) (4) ("Radical right (SVP)")
	margins, at(ATTR_CULTCON=(3) PARTY=(3))
		post results_party_SES ("`SES'") (`wrker') (r(table)[1,1]) (r(table)[5,1]) (r(table)[6,1]) (5) ("Center-right / liberals (FDP)")
	margins, at(ATTR_CULTCON=(3) PARTY=(5))
		post results_party_SES ("`SES'") (`wrker') (r(table)[1,1]) (r(table)[5,1]) (r(table)[6,1]) (6) ("Center-right / Christian democrats (Mitte)")
	margins, at(ATTR_CULTCON=(3) PARTY=(2))
		post results_party_SES ("`SES'") (`wrker') (r(table)[1,1]) (r(table)[5,1]) (r(table)[6,1]) (7) ("Center-left / social democrats (SP)")
	margins, at(ATTR_CULTCON=(3) PARTY=(6))
		post results_party_SES ("`SES'") (`wrker') (r(table)[1,1]) (r(table)[5,1]) (r(table)[6,1]) (8) ("Green-liberals (GLP)")
	margins, at(ATTR_CULTCON=(3) PARTY=(4))
		post results_party_SES ("`SES'") (`wrker') (r(table)[1,1]) (r(table)[5,1]) (r(table)[6,1]) (9) ("Greens (GPS)") 
restore
}
foreach lowsss of numlist 0 1 {
preserve
keep if LOWSSS == `lowsss'
local SES = "LOWSSS"
reg CHOICE_DV i.ATTR_GENDER i.ATTR_EDUCATION i.ATTR_ECONPOS i.ATTR_CULTPOS i.ATTR_ORIGIN i.ATTR_CULTCON, vce(cluster record)
	margins, at(ATTR_CULTCON=(3))
		post results_party_SES ("`SES'") (`lowsss') (r(table)[1,1]) (r(table)[5,1]) (r(table)[6,1]) (1.5) ("Overall")
reg CHOICE_DV i.ATTR_GENDER##i.PARTY i.ATTR_EDUCATION##i.PARTY i.ATTR_ECONPOS##i.PARTY i.ATTR_CULTPOS##i.PARTY i.ATTR_ORIGIN##i.PARTY i.ATTR_CULTCON##i.PARTY, vce(cluster record)
	margins, at(ATTR_CULTCON=(3) PARTY=(1))
		post results_party_SES ("`SES'") (`lowsss') (r(table)[1,1]) (r(table)[5,1]) (r(table)[6,1]) (4) ("Radical right (SVP)")
	margins, at(ATTR_CULTCON=(3) PARTY=(3))
		post results_party_SES ("`SES'") (`lowsss') (r(table)[1,1]) (r(table)[5,1]) (r(table)[6,1]) (5) ("Center-right / liberals (FDP)")
	margins, at(ATTR_CULTCON=(3) PARTY=(5))
		post results_party_SES ("`SES'") (`lowsss') (r(table)[1,1]) (r(table)[5,1]) (r(table)[6,1]) (6) ("Center-right / Christian democrats (Mitte)")
	margins, at(ATTR_CULTCON=(3) PARTY=(2))
		post results_party_SES ("`SES'") (`lowsss') (r(table)[1,1]) (r(table)[5,1]) (r(table)[6,1]) (7) ("Center-left / social democrats (SP)")
	margins, at(ATTR_CULTCON=(3) PARTY=(6))
		post results_party_SES ("`SES'") (`lowsss') (r(table)[1,1]) (r(table)[5,1]) (r(table)[6,1]) (8) ("Green-liberals (GLP)")
	margins, at(ATTR_CULTCON=(3) PARTY=(4))
		post results_party_SES ("`SES'") (`lowsss') (r(table)[1,1]) (r(table)[5,1]) (r(table)[6,1]) (9) ("Greens (GPS)") 
restore
}

postclose results_party_SES
use results_party_SES, clear
	replace y = -y
	replace SESval = 1 if SES == "NONTERTIARY2" & SESval == 1
	replace SESval = 10 if SES == "NONTERTIARY2" & SESval == 0
	replace SESval = 2 if SES == "LOWINC" & SESval == 1 
	replace SESval = 20 if SES == "LOWINC" & SESval == 0 
	replace SESval = 3 if SES == "WORKER" & SESval == 1
	replace SESval = 30 if SES == "WORKER" & SESval == 0
	replace SESval = 4 if SES == "LOWSSS" & SESval == 1
	replace SESval = 40 if SES == "LOWSSS" & SESval == 0
	lab def SESval 1 `""Subsample 1a:" "Non-tertiary educated voters""' 10 `""Subsample 1b:" "Tertiary educated voters""' ///
		2 `""Subsample 2a:" "Low income (decile 1-5)""' 20 `""Subsample 2b:" "High income (decile 6-10)""' ///
		3 `""Subsample 3a:" "Production/service worker""' 30 `""Subsample 3b:" "Non-working class voter""' ///
		4 `""Subsample 4a:" "Low subj. soc. status (0-5)""' 40 `""Subsample 4b:" "High subj. soc. status (6-10)""'
	lab val SESval SESval

twoway scatter y b, subtitle(,size(*0.8)) || rcap LB95 UB95 y, horizontal by(SESval, note("") ///
	title("                                                               Candidate enjoys going to drink a beer in favourite pub (working-class cultural consumption)", size(*0.65)) ///
	row(2) legend(off)  scale(*1.2) imargin(*2)) yscale(range(0 -9.5)) xline(0.5, lcol(gs6) lpattern(solid)) ///
	ytitle("") ylab(-1.5 "Overall (all voters)" -4 "Radical right (SVP) voters" -5 "Center-right / liberals (FDP) voters" ///
	-6 "Center-right / Christian dem. (Mitte) voters" -7 "Center-left / social democratic (SP) voters" ///
	-8 "Green-liberal (GLP) voters" -9 "Green (GPS) voters", labcol(gs0)) xlab(0.4(0.1)0.6, labcol(gs6) format(%3.2f)) ///
	xtitle("                                                                     Party leader choice probability (marginal means)", col(gs6) size(*0.7)) xsize(7)
	
*--------------------------------------------------------------*
**# Figure 4: Effects of beer attribute, by party and gender ***
*--------------------------------------------------------------*
	
use SYMBREP_FINAL, clear
cap postclose results_party_gender
postfile results_party_gender WOMAN b LB95 UB95 y str50 ylab using results_party_gender, replace

foreach gndr of numlist 0 1 {
preserve
keep if WOMAN == `gndr'
reg CHOICE_DV i.ATTR_GENDER i.ATTR_EDUCATION i.ATTR_ECONPOS i.ATTR_CULTPOS i.ATTR_ORIGIN i.ATTR_CULTCON, vce(cluster record)
	margins, at(ATTR_CULTCON=(3))
		post results_party_gender (`gndr') (r(table)[1,1]) (r(table)[5,1]) (r(table)[6,1]) (1.5) ("Overall")
reg CHOICE_DV i.ATTR_GENDER##i.PARTY i.ATTR_EDUCATION##i.PARTY i.ATTR_ECONPOS##i.PARTY i.ATTR_CULTPOS##i.PARTY i.ATTR_ORIGIN##i.PARTY i.ATTR_CULTCON##i.PARTY, vce(cluster record)
	margins, at(ATTR_CULTCON=(3) PARTY=(1))
		post results_party_gender (`gndr') (r(table)[1,1]) (r(table)[5,1]) (r(table)[6,1]) (4) ("Radical right (SVP)")
	margins, at(ATTR_CULTCON=(3) PARTY=(3))
		post results_party_gender (`gndr') (r(table)[1,1]) (r(table)[5,1]) (r(table)[6,1]) (5) ("Center-right / liberals (FDP)")
	margins, at(ATTR_CULTCON=(3) PARTY=(5))
		post results_party_gender (`gndr') (r(table)[1,1]) (r(table)[5,1]) (r(table)[6,1]) (6) ("Center-right / Christian democrats (Mitte)")
	margins, at(ATTR_CULTCON=(3) PARTY=(2))
		post results_party_gender (`gndr') (r(table)[1,1]) (r(table)[5,1]) (r(table)[6,1]) (7) ("Center-left / social democrats (SP)")
	margins, at(ATTR_CULTCON=(3) PARTY=(6))
		post results_party_gender (`gndr') (r(table)[1,1]) (r(table)[5,1]) (r(table)[6,1]) (8) ("Green-liberals (GLP)")
	margins, at(ATTR_CULTCON=(3) PARTY=(4))
		post results_party_gender (`gndr') (r(table)[1,1]) (r(table)[5,1]) (r(table)[6,1]) (9) ("Greens (GPS)")
restore
}		
reg CHOICE_DV i.ATTR_GENDER##i.PARTY i.ATTR_EDUCATION##i.PARTY i.ATTR_ECONPOS##i.PARTY i.ATTR_CULTPOS##i.PARTY i.ATTR_ORIGIN##i.PARTY i.ATTR_CULTCON##i.PARTY if WOMAN == 0, vce(cluster record)
	margins rb1.PARTY, at(ATTR_CULTCON=3)
reg CHOICE_DV i.ATTR_GENDER##i.PARTY i.ATTR_EDUCATION##i.PARTY i.ATTR_ECONPOS##i.PARTY i.ATTR_CULTPOS##i.PARTY i.ATTR_ORIGIN##i.PARTY i.ATTR_CULTCON##i.PARTY if WOMAN == 1, vce(cluster record)
	margins rb1.PARTY, at(ATTR_CULTCON=3)

postclose results_party_gender
use results_party_gender, clear
	replace y = -y
	lab def WOMAN 0 "Subsample: men" 1 "Subsample: women"
	lab val WOMAN WOMAN

twoway scatter y b, subtitle(,size(*0.8)) || rcap LB95 UB95 y, horizontal by(WOMAN, note("") ///
	title("                                                             Candidate enjoys going to drink a beer in favourite pub" ///
	"                                                                   (working-class cultural consumption)", size(*0.65)) ///
	legend(off)  scale(*1.7) imargin(*6)) ///
	yscale(range(0 -9.5)) xline(0.5, lcol(gs6) lpattern(solid)) ///
	ytitle("") ylab(-1.5 "Overall (all voters)" -4 "Radical right (SVP) voters" -5 "Center-right / liberals (FDP) voters" ///
	-6 "Center-right / Christian dem. (Mitte) voters" -7 "Center-left / social democratic (SP) voters" ///
	-8 "Green-liberal (GLP) voters" -9 "Green (GPS) voters", labcol(gs0)) xlab(, labcol(gs6) format(%3.2f)) ///
	xtitle("                                                                     Party leader choice probability (marginal means)", col(gs6) size(*0.75)) ysize(3)
	
********************************************************************************	
**# APPENDIX -------------------------------------------------------------------
********************************************************************************

*----------------------------------------------------------------------------------------------------*
**# Figure C1: AMCE of beer attribute relative to wine attribute of cultural consumption, by party ***
*----------------------------------------------------------------------------------------------------*

use SYMBREP_FINAL, clear
	
cap postclose results_ACME_party
postfile results_ACME_party ATTR_CULTCON b LB95 UB95 y str50 ylab using results_ACME_party, replace

reg CHOICE_DV i.ATTR_GENDER i.ATTR_EDUCATION i.ATTR_ECONPOS i.ATTR_CULTPOS i.ATTR_ORIGIN i.ATTR_CULTCON, vce(cluster record)	
	margins, at(ATTR_CULTCON=(1 3)) contrast(atcontrast(r._at))
		post results_ACME_party (1) (r(table)[1,1]) (r(table)[5,1]) (r(table)[6,1]) (1.5) ("Overall")
reg CHOICE_DV i.ATTR_GENDER##i.PARTY i.ATTR_EDUCATION##i.PARTY i.ATTR_ECONPOS##i.PARTY i.ATTR_CULTPOS##i.PARTY i.ATTR_ORIGIN##i.PARTY i.ATTR_CULTCON##i.PARTY, vce(cluster record)
	margins, at(ATTR_CULTCON=(1 3) PARTY=(1)) contrast(atcontrast(r._at))
		post results_ACME_party (1) (r(table)[1,1]) (r(table)[5,1]) (r(table)[6,1]) (4) ("Radical right (SVP)")
	margins, at(ATTR_CULTCON=(1 3) PARTY=(3)) contrast(atcontrast(r._at))
		post results_ACME_party (1) (r(table)[1,1]) (r(table)[5,1]) (r(table)[6,1]) (5) ("Center-right / liberals (FDP)")
	margins, at(ATTR_CULTCON=(1 3) PARTY=(5)) contrast(atcontrast(r._at))
		post results_ACME_party (1) (r(table)[1,1]) (r(table)[5,1]) (r(table)[6,1]) (6) ("Center-right / Christian democrats (Mitte)")
	margins, at(ATTR_CULTCON=(1 3) PARTY=(2)) contrast(atcontrast(r._at))
		post results_ACME_party (1) (r(table)[1,1]) (r(table)[5,1]) (r(table)[6,1]) (7) ("Center-left / social democrats (SP)")
	margins, at(ATTR_CULTCON=(1 3) PARTY=(6)) contrast(atcontrast(r._at))
		post results_ACME_party (1) (r(table)[1,1]) (r(table)[5,1]) (r(table)[6,1]) (8) ("Green-liberals (GLP)")
	margins, at(ATTR_CULTCON=(1 3) PARTY=(4)) contrast(atcontrast(r._at))
		post results_ACME_party (1) (r(table)[1,1]) (r(table)[5,1]) (r(table)[6,1]) (9) ("Greens (GPS)")
		
postclose results_ACME_party
use results_ACME_party, clear
	replace y = -y
	lab def ATTR_CULTCON 1 `""Candidate enjoys going to drink a beer in favourite pub" "(working-class cultural consumption)" " " "{it:[Reference group: Candidate enjoys listening to classical music}" "{it:with a glass of wine (upper-class cultural consumption)]}" " ""'
	lab val ATTR_CULTCON ATTR_CULTCON
grstyle set color gs0 gs0	

twoway scatter y b, subtitle(,size(*0.7)) || rcap LB95 UB95 y, horizontal by(ATTR_CULTCON, note("") legend(off) scale(*1.35)) ///
	yscale(range(0 -10)) xline(0, lcol(gs0)) xlab(,format(%3.1f)) ///
	ytitle("") ylab(-1.5 "Overall (all voters)" -4 "Radical right (SVP) voters" -5 "Center-right / liberals (FDP) voters" ///
	-6 "Center-right / Christian dem. (Mitte) voters" -7 "Center-left / social democratic (SP) voters" ///
	-8 "Green-liberal (GLP) voters" -9 "Green (GPS) voters", labcol(gs0)) ///
	xtitle("                                                                    Party leader choice probability (AMCE)", col(gs6) size(*0.8)) ///
	xsize(7) aspect(1.1)

*----------------------------------------------------------------------------------------------------*
**# Figure C2: AMCE of beer attribute relative to wine attribute of cultural consumption, by party ***
*----------------------------------------------------------------------------------------------------*
	
use SYMBREP_FINAL, clear

postfile variation_cand interaction_group str20 interaction_value svp b LB95 UB95 using variation_cand, replace
foreach svp of numlist 0 1 {
reg CHOICE_DV  i.ATTR_EDUCATION##i.SVP i.ATTR_ECONPOS##i.SVP i.ATTR_CULTPOS##i.SVP i.ATTR_ORIGIN##i.SVP i.ATTR_CULTCON##i.SVP##i.ATTR_GENDER, vce(cluster record)
	margins, dydx(3.ATTR_CULTCON) at(ATTR_GENDER=(1) SVP=(`svp'))
		post variation_cand (1) ("Male candidates") (`svp') (r(table)[1,2]) (r(table)[5,2]) (r(table)[6,2])
	margins, dydx(3.ATTR_CULTCON) at(ATTR_GENDER=(2) SVP=(`svp'))
		post variation_cand (1) ("Female candidates") (`svp') (r(table)[1,2]) (r(table)[5,2]) (r(table)[6,2])
		post variation_cand (1) ("") (`svp') (.) (.) (.)
		
reg CHOICE_DV  ATTR_GENDER##i.SVP i.ATTR_ECONPOS##i.SVP i.ATTR_CULTPOS##i.SVP i.ATTR_ORIGIN##i.SVP i.ATTR_CULTCON##i.SVP##i.ATTR_EDUCATION, vce(cluster record)
	margins, dydx(3.ATTR_CULTCON) at(ATTR_EDUCATION=(1) SVP=(`svp'))
		post variation_cand (2) ("Candidates with a university degree") (`svp') (r(table)[1,2]) (r(table)[5,2]) (r(table)[6,2])
	margins, dydx(3.ATTR_CULTCON) at(ATTR_EDUCATION=(2) SVP=(`svp'))
		post variation_cand (2) ("Candidates with a vocational degree") (`svp') (r(table)[1,2]) (r(table)[5,2]) (r(table)[6,2])
		post variation_cand (2) ("") (`svp') (.) (.) (.)

reg CHOICE_DV  ATTR_GENDER##i.SVP i.SVP##i.ATTR_EDUCATION i.ATTR_ECONPOS##i.SVP i.ATTR_CULTPOS##i.SVP  i.ATTR_CULTCON##i.SVP##i.ATTR_ORIGIN, vce(cluster record)
	margins, dydx(3.ATTR_CULTCON) at(ATTR_ORIGIN=(1) SVP=(`svp'))
		post variation_cand (3) ("Candidates from upper-class origin (wealthy family)") (`svp') (r(table)[1,2]) (r(table)[5,2]) (r(table)[6,2])
	margins, dydx(3.ATTR_CULTCON) at(ATTR_ORIGIN=(2) SVP=(`svp'))
		post variation_cand (3) ("Candidates from middle-class origin (teacher family)") (`svp') (r(table)[1,2]) (r(table)[5,2]) (r(table)[6,2])
	margins, dydx(3.ATTR_CULTCON) at(ATTR_ORIGIN=(3) SVP=(`svp'))
		post variation_cand (3) ("Candidates from working-class origin (working-class family)") (`svp') (r(table)[1,2]) (r(table)[5,2]) (r(table)[6,2])
		post variation_cand (3) ("") (`svp') (.) (.) (.)

reg CHOICE_DV  ATTR_GENDER##i.SVP i.SVP##i.ATTR_EDUCATION i.ATTR_CULTPOS##i.SVP i.ATTR_ORIGIN##i.SVP  i.ATTR_CULTCON##i.SVP##i.ATTR_ECONPOS, vce(cluster record)
	margins, dydx(3.ATTR_CULTCON) at(ATTR_ECONPOS=(1) SVP=(`svp'))
		post variation_cand (4) ("Candidates with left-wing economic attitudes within party") (`svp') (r(table)[1,2]) (r(table)[5,2]) (r(table)[6,2])
	margins, dydx(3.ATTR_CULTCON) at(ATTR_ECONPOS=(2) SVP=(`svp'))
		post variation_cand (4) ("Candidates with right-wing economic attitudes within party") (`svp') (r(table)[1,2]) (r(table)[5,2]) (r(table)[6,2])
		post variation_cand (4) ("") (`svp') (.) (.) (.)
	
reg CHOICE_DV  ATTR_GENDER##i.SVP i.SVP##i.ATTR_EDUCATION i.ATTR_ECONPOS##i.SVP i.ATTR_ORIGIN##i.SVP  i.ATTR_CULTCON##i.SVP##i.ATTR_CULTPOS, vce(cluster record)
	margins, dydx(3.ATTR_CULTCON) at(ATTR_CULTPOS=(1) SVP=(`svp'))
		post variation_cand (5) ("Candidates with left-wing cultural attitudes within party") (`svp') (r(table)[1,2]) (r(table)[5,2]) (r(table)[6,2])
	margins, dydx(3.ATTR_CULTCON) at(ATTR_CULTPOS=(2) SVP=(`svp'))
		post variation_cand (5) ("Candidates with right-wing cultural attitudes within party") (`svp') (r(table)[1,2]) (r(table)[5,2]) (r(table)[6,2])
		post variation_cand (5) ("") (`svp') (.) (.) (.)
	
}	
postclose variation_cand
use variation_cand, clear
	bysort svp: gen y = -[_n]
	replace svp = 2 if svp == 0
	lab def svp 1 "Radical right (SVP) voters" 2 "Non-radical right (non-SVP) voters"
	lab val svp svp
	scatter y b, subtitle(,size(*0.75)) || rcap LB95 UB95 y, by(svp, legend(off) note("") scale(*1.4) imargin(*3) ///
		title("                                                             Candidate enjoys going to drink a beer in favourite pub" ///
		"                                                             (working-class cultural consumption)" " " ///
		"{it:                                                             [Reference group: Candidate enjoys listening to classical music}" ///
		"{it:                                                             with a glass of wine (upper-class cultural consumption)]}" " ", size(*0.6)) ) ///
		horizontal yscale(range(0 -3)) xline(0, lcol(gs6)) xlab(,format(%3.1f)) ///
		ytitle("") ylab(-1 "Male candidate" -2 "Female candidate" -4 "Candidate has a university degree" -5 "Candidate has a vocational degree" ///
		-7 "Candidate from wealthy family" -8 "Candidate from teacher family" -9 "Candidate from working-class family" ///
		-11 "Candidate left-wing on economic issues" -12 "Candidate right-wing on economic issues" ///
		-14 "Candidate left-wing on cultural issues" -15 "Candidate right-wing on cultural issues", labcol(gs0)) ///
		xtitle("                                                                    Party leader choice probability (AMCE)", col(gs6) size(*0.7)) ///
		xsize(7) aspect(1.5)
	
*--------------------------------------------------------------------------------*
**# Figure E1: Effect of candidate's gender on party leader choice probability ***
*--------------------------------------------------------------------------------*
	
use SYMBREP_FINAL, clear
cap postclose results_party
postfile results_party ATTR_GENDER b LB95 UB95 y str50 ylab using results_party, replace

foreach attgender of numlist 1 2 {
reg CHOICE_DV i.ATTR_GENDER i.ATTR_EDUCATION i.ATTR_ECONPOS i.ATTR_CULTPOS i.ATTR_ORIGIN i.ATTR_CULTCON, vce(cluster record)	
	margins, at(ATTR_GENDER=(`attgender'))
		post results_party (`attgender') (r(table)[1,1]) (r(table)[5,1]) (r(table)[6,1]) (1.5) ("Overall")
reg CHOICE_DV i.ATTR_GENDER##i.PARTY i.ATTR_EDUCATION##i.PARTY i.ATTR_ECONPOS##i.PARTY i.ATTR_CULTPOS##i.PARTY i.ATTR_ORIGIN##i.PARTY i.ATTR_CULTCON##i.PARTY, vce(cluster record)
	margins, at(ATTR_GENDER=(`attgender') PARTY=(1))
		post results_party (`attgender') (r(table)[1,1]) (r(table)[5,1]) (r(table)[6,1]) (4) ("Radical right (SVP)")
	margins, at(ATTR_GENDER=(`attgender') PARTY=(3))
		post results_party (`attgender') (r(table)[1,1]) (r(table)[5,1]) (r(table)[6,1]) (5) ("Center-right / liberals (FDP)")
	margins, at(ATTR_GENDER=(`attgender') PARTY=(5))
		post results_party (`attgender') (r(table)[1,1]) (r(table)[5,1]) (r(table)[6,1]) (6) ("Center-right / Christian democrats (Mitte)")
	margins, at(ATTR_GENDER=(`attgender') PARTY=(2))
		post results_party (`attgender') (r(table)[1,1]) (r(table)[5,1]) (r(table)[6,1]) (7) ("Center-left / social democrats (SP)")
	margins, at(ATTR_GENDER=(`attgender') PARTY=(6))
		post results_party (`attgender') (r(table)[1,1]) (r(table)[5,1]) (r(table)[6,1]) (8) ("Green-liberals (GLP)")
	margins, at(ATTR_GENDER=(`attgender') PARTY=(4))
		post results_party (`attgender') (r(table)[1,1]) (r(table)[5,1]) (r(table)[6,1]) (9) ("Greens (GPS)")
}		
	margins rb1.PARTY, at(ATTR_CULTCON=3)
		
postclose results_party
use results_party, clear
	replace y = -y
	lab def ATTR_GENDER 1 `"" " "Male" "candidate""' 2 `"" " "Female" "candidate""'
	lab val ATTR_GENDER ATTR_GENDER
grstyle set color gs0 gs0	

twoway scatter y b, subtitle(,size(*0.75)) || rcap LB95 UB95 y, horizontal by(ATTR_GENDER, note("") legend(off) scale(*1.9) row(1) imargin(*6)) ///
	yscale(range(0 -9.5)) xline(0.5, lcol(gs6) lpattern(solid)) ///
	ytitle("", col(gs6) size(*0.8)) ylab(-1.5 "Overall (all voters)" -4 "Radical right (SVP) voters" -5 "Center-right / liberals (FDP) voters" ///
	-6 "Center-right / Christian dem. (Mitte) voters" -7 "Center-left / social democratic (SP) voters" ///
	-8 "Green-liberal (GLP) voters" -9 "Green (GPS) voters", labcol(gs0)) xlab(, labcol(gs6) format(%3.2f)) ///
	xtitle("                                                                     Party leader choice probability (marginal means)", col(gs6) size(*0.7)) ysize(2.4) ///
	name(byparty_gender, replace)

*-----------------------------------------------------------------------------------*
**# Figure E2: Effect of candidate's education on party leader choice probability ***
*-----------------------------------------------------------------------------------*

use SYMBREP_FINAL, clear
cap postclose results_party
postfile results_party ATTR_EDUCATION b LB95 UB95 y str50 ylab using results_party, replace

foreach atteduc of numlist 1 2 {
reg CHOICE_DV i.ATTR_GENDER i.ATTR_EDUCATION i.ATTR_ECONPOS i.ATTR_CULTPOS i.ATTR_GENDER i.ATTR_CULTCON, vce(cluster record)	
	margins, at(ATTR_EDUCATION=(`atteduc'))
		post results_party (`atteduc') (r(table)[1,1]) (r(table)[5,1]) (r(table)[6,1]) (1.5) ("Overall")
reg CHOICE_DV i.ATTR_GENDER##i.PARTY i.ATTR_EDUCATION##i.PARTY i.ATTR_ECONPOS##i.PARTY i.ATTR_CULTPOS##i.PARTY i.ATTR_GENDER##i.PARTY i.ATTR_CULTCON##i.PARTY, vce(cluster record)
	margins, at(ATTR_EDUCATION=(`atteduc') PARTY=(1))
		post results_party (`atteduc') (r(table)[1,1]) (r(table)[5,1]) (r(table)[6,1]) (4) ("Radical right (SVP)")
	margins, at(ATTR_EDUCATION=(`atteduc') PARTY=(3))
		post results_party (`atteduc') (r(table)[1,1]) (r(table)[5,1]) (r(table)[6,1]) (5) ("Center-right / liberals (FDP)")
	margins, at(ATTR_EDUCATION=(`atteduc') PARTY=(5))
		post results_party (`atteduc') (r(table)[1,1]) (r(table)[5,1]) (r(table)[6,1]) (6) ("Center-right / Christian democrats (Mitte)")
	margins, at(ATTR_EDUCATION=(`atteduc') PARTY=(2))
		post results_party (`atteduc') (r(table)[1,1]) (r(table)[5,1]) (r(table)[6,1]) (7) ("Center-left / social democrats (SP)")
	margins, at(ATTR_EDUCATION=(`atteduc') PARTY=(6))
		post results_party (`atteduc') (r(table)[1,1]) (r(table)[5,1]) (r(table)[6,1]) (8) ("Green-liberals (GLP)")
	margins, at(ATTR_EDUCATION=(`atteduc') PARTY=(4))
		post results_party (`atteduc') (r(table)[1,1]) (r(table)[5,1]) (r(table)[6,1]) (9) ("Greens (GPS)")
}		
	margins rb1.PARTY, at(ATTR_CULTCON=3)
		
postclose results_party
use results_party, clear
	replace y = -y
	lab def ATTR_EDUCATION 1 `"" " "Candidate with a" "university degree""' 2 `"" " "Candidate with a" "vocational degree""'
	lab val ATTR_EDUCATION ATTR_EDUCATION

twoway scatter y b, subtitle(,size(*0.75)) || rcap LB95 UB95 y, horizontal by(ATTR_EDUCATION, note("") legend(off) scale(*1.9) row(1) imargin(*6)) ///
	yscale(range(0 -9.5)) xline(0.5, lcol(gs6) lpattern(solid)) ///
	ytitle("", col(gs6) size(*0.8)) ylab(-1.5 "Overall (all voters)" -4 "Radical right (SVP) voters" -5 "Center-right / liberals (FDP) voters" ///
	-6 "Center-right / Christian dem. (Mitte) voters" -7 "Center-left / social democratic (SP) voters" ///
	-8 "Green-liberal (GLP) voters" -9 "Green (GPS) voters", labcol(gs0)) xlab(, labcol(gs6) format(%3.2f)) ///
	xtitle("                                                                     Party leader choice probability (marginal means)", col(gs6) size(*0.7)) ysize(2.4) ///
	name(byparty_education, replace)
	
*--------------------------------------------------------------------------------------*
**# Figure E3: Effect of candidate's class origin on party leader choice probability ***
*--------------------------------------------------------------------------------------*

use SYMBREP_FINAL, clear
cap postclose results_party
postfile results_party ATTR_ORIGIN b LB95 UB95 y str50 ylab using results_party, replace

foreach attorigin of numlist 1 2 3 {
reg CHOICE_DV i.ATTR_GENDER i.ATTR_EDUCATION i.ATTR_ECONPOS i.ATTR_CULTPOS i.ATTR_ORIGIN i.ATTR_CULTCON, vce(cluster record)	
	margins, at(ATTR_ORIGIN=(`attorigin'))
		post results_party (`attorigin') (r(table)[1,1]) (r(table)[5,1]) (r(table)[6,1]) (1.5) ("Overall")
reg CHOICE_DV i.ATTR_GENDER##i.PARTY i.ATTR_EDUCATION##i.PARTY i.ATTR_ECONPOS##i.PARTY i.ATTR_CULTPOS##i.PARTY i.ATTR_ORIGIN##i.PARTY i.ATTR_CULTCON##i.PARTY, vce(cluster record)
	margins, at(ATTR_ORIGIN=(`attorigin') PARTY=(1))
		post results_party (`attorigin') (r(table)[1,1]) (r(table)[5,1]) (r(table)[6,1]) (4) ("Radical right (SVP)")
	margins, at(ATTR_ORIGIN=(`attorigin') PARTY=(3))
		post results_party (`attorigin') (r(table)[1,1]) (r(table)[5,1]) (r(table)[6,1]) (5) ("Center-right / liberals (FDP)")
	margins, at(ATTR_ORIGIN=(`attorigin') PARTY=(5))
		post results_party (`attorigin') (r(table)[1,1]) (r(table)[5,1]) (r(table)[6,1]) (6) ("Center-right / Christian democrats (Mitte)")
	margins, at(ATTR_ORIGIN=(`attorigin') PARTY=(2))
		post results_party (`attorigin') (r(table)[1,1]) (r(table)[5,1]) (r(table)[6,1]) (7) ("Center-left / social democrats (SP)")
	margins, at(ATTR_ORIGIN=(`attorigin') PARTY=(6))
		post results_party (`attorigin') (r(table)[1,1]) (r(table)[5,1]) (r(table)[6,1]) (8) ("Green-liberals (GLP)")
	margins, at(ATTR_ORIGIN=(`attorigin') PARTY=(4))
		post results_party (`attorigin') (r(table)[1,1]) (r(table)[5,1]) (r(table)[6,1]) (9) ("Greens (GPS)")
}		
	margins rb1.PARTY, at(ATTR_CULTCON=3)
		
postclose results_party
use results_party, clear
	replace y = -y
	lab def ATTR_ORIGIN 1 `""Candidate from""upper-class origin" "(wealthy family)""' 2 `""Candidate from" "middle-class origin" "(teacher family)""' 3 `""Candidate from" "working-class origin" "(working-class family)""'
	lab val ATTR_ORIGIN ATTR_ORIGIN
grstyle set color gs0 gs0	

twoway scatter y b, subtitle(,size(*0.75)) || rcap LB95 UB95 y, horizontal by(ATTR_ORIGIN, note("") legend(off) scale(*2.1) row(1) imargin(*6)) ///
	yscale(range(0 -9.5)) xline(0.5, lcol(gs6) lpattern(solid)) ///
	ytitle("", col(gs6) size(*0.8)) ylab(-1.5 "Overall (all voters)" -4 "Radical right (SVP) voters" -5 "Center-right / liberals (FDP) voters" ///
	-6 "Center-right / Christian dem. (Mitte) voters" -7 "Center-left / social democratic (SP) voters" ///
	-8 "Green-liberal (GLP) voters" -9 "Green (GPS) voters", labcol(gs0)) xlab(, labcol(gs6) format(%3.2f)) ///
	xtitle("                                                                     Party leader choice probability (marginal means)", col(gs6) size(*0.7)) ysize(2.05) ///
	name(byparty_origin, replace)

*---------------------------------------------------------------------------------------------------------------------*
**# Figure E4: Effect of candidate's attitudes on economic issues (within party) on party leader choice probability ***
*---------------------------------------------------------------------------------------------------------------------*

use SYMBREP_FINAL, clear
cap postclose results_party
postfile results_party ATTR_ECONPOS b LB95 UB95 y str50 ylab using results_party, replace

foreach atteconpos of numlist 1 2 {
reg CHOICE_DV i.ATTR_GENDER i.ATTR_EDUCATION i.ATTR_ECONPOS i.ATTR_CULTPOS i.ATTR_GENDER i.ATTR_CULTCON, vce(cluster record)	
	margins, at(ATTR_ECONPOS=(`atteconpos'))
		post results_party (`atteconpos') (r(table)[1,1]) (r(table)[5,1]) (r(table)[6,1]) (1.5) ("Overall")
reg CHOICE_DV i.ATTR_GENDER##i.PARTY i.ATTR_EDUCATION##i.PARTY i.ATTR_ECONPOS##i.PARTY i.ATTR_CULTPOS##i.PARTY i.ATTR_GENDER##i.PARTY i.ATTR_CULTCON##i.PARTY, vce(cluster record)
	margins, at(ATTR_ECONPOS=(`atteconpos') PARTY=(1))
		post results_party (`atteconpos') (r(table)[1,1]) (r(table)[5,1]) (r(table)[6,1]) (4) ("Radical right (SVP)")
	margins, at(ATTR_ECONPOS=(`atteconpos') PARTY=(3))
		post results_party (`atteconpos') (r(table)[1,1]) (r(table)[5,1]) (r(table)[6,1]) (5) ("Center-right / liberals (FDP)")
	margins, at(ATTR_ECONPOS=(`atteconpos') PARTY=(5))
		post results_party (`atteconpos') (r(table)[1,1]) (r(table)[5,1]) (r(table)[6,1]) (6) ("Center-right / Christian democrats (Mitte)")
	margins, at(ATTR_ECONPOS=(`atteconpos') PARTY=(2))
		post results_party (`atteconpos') (r(table)[1,1]) (r(table)[5,1]) (r(table)[6,1]) (7) ("Center-left / social democrats (SP)")
	margins, at(ATTR_ECONPOS=(`atteconpos') PARTY=(6))
		post results_party (`atteconpos') (r(table)[1,1]) (r(table)[5,1]) (r(table)[6,1]) (8) ("Green-liberals (GLP)")
	margins, at(ATTR_ECONPOS=(`atteconpos') PARTY=(4))
		post results_party (`atteconpos') (r(table)[1,1]) (r(table)[5,1]) (r(table)[6,1]) (9) ("Greens (GPS)")
}		
	margins rb1.PARTY, at(ATTR_CULTCON=3)
		
postclose results_party
use results_party, clear
	replace y = -y
	lab def ATTR_ECONPOS 1 `""Candidate with left-wing attitudes" "on economic issues (within party)""' 2 `""Candidate with right-wing attitudes" "on economic issues (within party)""'
	lab val ATTR_ECONPOS ATTR_ECONPOS
grstyle set color gs0 gs0	

twoway scatter y b, subtitle(,size(*0.75)) || rcap LB95 UB95 y, horizontal by(ATTR_ECONPOS, note("") legend(off) scale(*1.9) row(1) imargin(*6)) ///
	yscale(range(0 -9.5)) xline(0.5, lcol(gs6) lpattern(solid)) ///
	ytitle("", col(gs6) size(*0.8)) ylab(-1.5 "Overall (all voters)" -4 "Radical right (SVP) voters" -5 "Center-right / liberals (FDP) voters" ///
	-6 "Center-right / Christian dem. (Mitte) voters" -7 "Center-left / social democratic (SP) voters" ///
	-8 "Green-liberal (GLP) voters" -9 "Green (GPS) voters", labcol(gs0)) xlab(, labcol(gs6) format(%3.2f)) ///
	xtitle("                                                                     Party leader choice probability (marginal means)", col(gs6) size(*0.7)) ysize(2.4) ///
	name(byparty_econpos, replace)

*---------------------------------------------------------------------------------------------------------------------*
**# Figure E5: Effect of candidate's attitudes on cultural issues (within party) on party leader choice probability ***
*---------------------------------------------------------------------------------------------------------------------*

use SYMBREP_FINAL, clear
cap postclose results_party
postfile results_party ATTR_CULTPOS b LB95 UB95 y str50 ylab using results_party, replace

foreach attcultpos of numlist 1 2 {
reg CHOICE_DV i.ATTR_GENDER i.ATTR_EDUCATION i.ATTR_ECONPOS i.ATTR_CULTPOS i.ATTR_GENDER i.ATTR_CULTCON, vce(cluster record)	
	margins, at(ATTR_CULTPOS=(`attcultpos'))
		post results_party (`attcultpos') (r(table)[1,1]) (r(table)[5,1]) (r(table)[6,1]) (1.5) ("Overall")
reg CHOICE_DV i.ATTR_GENDER##i.PARTY i.ATTR_EDUCATION##i.PARTY i.ATTR_ECONPOS##i.PARTY i.ATTR_CULTPOS##i.PARTY i.ATTR_GENDER##i.PARTY i.ATTR_CULTCON##i.PARTY, vce(cluster record)
	margins, at(ATTR_CULTPOS=(`attcultpos') PARTY=(1))
		post results_party (`attcultpos') (r(table)[1,1]) (r(table)[5,1]) (r(table)[6,1]) (4) ("Radical right (SVP)")
	margins, at(ATTR_CULTPOS=(`attcultpos') PARTY=(3))
		post results_party (`attcultpos') (r(table)[1,1]) (r(table)[5,1]) (r(table)[6,1]) (5) ("Center-right / liberals (FDP)")
	margins, at(ATTR_CULTPOS=(`attcultpos') PARTY=(5))
		post results_party (`attcultpos') (r(table)[1,1]) (r(table)[5,1]) (r(table)[6,1]) (6) ("Center-right / Christian democrats (Mitte)")
	margins, at(ATTR_CULTPOS=(`attcultpos') PARTY=(2))
		post results_party (`attcultpos') (r(table)[1,1]) (r(table)[5,1]) (r(table)[6,1]) (7) ("Center-left / social democrats (SP)")
	margins, at(ATTR_CULTPOS=(`attcultpos') PARTY=(6))
		post results_party (`attcultpos') (r(table)[1,1]) (r(table)[5,1]) (r(table)[6,1]) (8) ("Green-liberals (GLP)")
	margins, at(ATTR_CULTPOS=(`attcultpos') PARTY=(4))
		post results_party (`attcultpos') (r(table)[1,1]) (r(table)[5,1]) (r(table)[6,1]) (9) ("Greens (GPS)")
}		
	margins rb1.PARTY, at(ATTR_CULTCON=3)
		
postclose results_party
use results_party, clear
	replace y = -y
	lab def ATTR_CULTPOS 1 `""Candidate with left-wing attitudes" "on cultural issues (within party)""' 2 `""Candidate with right-wing attitudes" "on cultural issues (within party)""'
	lab val ATTR_CULTPOS ATTR_CULTPOS
grstyle set color gs0 gs0	

twoway scatter y b, subtitle(,size(*0.75)) || rcap LB95 UB95 y, horizontal by(ATTR_CULTPOS, note("") legend(off) scale(*1.9) row(1) imargin(*6)) ///
	yscale(range(0 -9.5)) xline(0.5, lcol(gs6) lpattern(solid)) ///
	ytitle("", col(gs6) size(*0.8)) ylab(-1.5 "Overall (all voters)" -4 "Radical right (SVP) voters" -5 "Center-right / liberals (FDP) voters" ///
	-6 "Center-right / Christian dem. (Mitte) voters" -7 "Center-left / social democratic (SP) voters" ///
	-8 "Green-liberal (GLP) voters" -9 "Green (GPS) voters", labcol(gs0)) xlab(, labcol(gs6) format(%3.2f)) ///
	xtitle("                                                                     Party leader choice probability (marginal means)", col(gs6) size(*0.7)) ysize(2.4) ///
	name(byparty_cultpos, replace)

*----------------------------------------------------------------------------------------------*
**# Figure E6: Effect of candidate's cultural consumption on party leader choice probability ***
*----------------------------------------------------------------------------------------------*

use SYMBREP_FINAL, clear
cap postclose results_party
postfile results_party ATTR_CULTCON b LB95 UB95 y str50 ylab using results_party, replace

foreach cultcon of numlist 1 2 3 {
reg CHOICE_DV i.ATTR_GENDER i.ATTR_EDUCATION i.ATTR_ECONPOS i.ATTR_CULTPOS i.ATTR_ORIGIN i.ATTR_CULTCON, vce(cluster record)	
	margins, at(ATTR_CULTCON=(`cultcon'))
		post results_party (`cultcon') (r(table)[1,1]) (r(table)[5,1]) (r(table)[6,1]) (1.5) ("Overall")
reg CHOICE_DV i.ATTR_GENDER##i.PARTY i.ATTR_EDUCATION##i.PARTY i.ATTR_ECONPOS##i.PARTY i.ATTR_CULTPOS##i.PARTY i.ATTR_ORIGIN##i.PARTY i.ATTR_CULTCON##i.PARTY, vce(cluster record)
	margins, at(ATTR_CULTCON=(`cultcon') PARTY=(1))
		post results_party (`cultcon') (r(table)[1,1]) (r(table)[5,1]) (r(table)[6,1]) (4) ("Radical right (SVP) voters")
	margins, at(ATTR_CULTCON=(`cultcon') PARTY=(3))
		post results_party (`cultcon') (r(table)[1,1]) (r(table)[5,1]) (r(table)[6,1]) (5) ("Center-right / liberals (FDP) voters")
	margins, at(ATTR_CULTCON=(`cultcon') PARTY=(5))
		post results_party (`cultcon') (r(table)[1,1]) (r(table)[5,1]) (r(table)[6,1]) (6) ("Center-right / Christian dem. (Mitte) voters")
	margins, at(ATTR_CULTCON=(`cultcon') PARTY=(2))
		post results_party (`cultcon') (r(table)[1,1]) (r(table)[5,1]) (r(table)[6,1]) (7) ("Center-left / social democratic (SP) voters")
	margins, at(ATTR_CULTCON=(`cultcon') PARTY=(6))
		post results_party (`cultcon') (r(table)[1,1]) (r(table)[5,1]) (r(table)[6,1]) (8) ("Green-liberal (GLP) voters")
	margins, at(ATTR_CULTCON=(`cultcon') PARTY=(4))
		post results_party (`cultcon') (r(table)[1,1]) (r(table)[5,1]) (r(table)[6,1]) (9) ("Green (GPS) voters")
}		
	margins rb1.PARTY, at(ATTR_CULTCON=2)
	margins gw.PARTY, at(ATTR_CULTCON=2)
		
postclose results_party
use results_party, clear
	replace y = -y
	lab def ATTR_CULTCON 1 `""Candidate enjoys listening to" "classical music with a glass of wine" "(upper-class cultural consumption)""' ///
		2 `""Candidate enjoys" "meeting friends" "in his/her spare time""' 3 `""Candidate enjoys going to" "drink a beer in favourite pub" "(working-class cultural consumption)""'
	lab val ATTR_CULTCON ATTR_CULTCON
grstyle set color gs0 gs0	

twoway scatter y b, subtitle(,size(*0.75)) || rcap LB95 UB95 y, horizontal by(ATTR_CULTCON, note("") legend(off) scale(*2.1) row(1) imargin(*6)) ///
	yscale(range(0 -9.5)) xline(0.5, lcol(gs6) lpattern(solid)) ///
	ytitle("", col(gs6) size(*0.8)) ylab(-1.5 "Overall (all voters)" -4 "Radical right (SVP) voters" -5 "Center-right / liberals (FDP) voters" ///
	-6 "Center-right / Christian dem. (Mitte) voters" -7 "Center-left / social democratic (SP) voters" ///
	-8 "Green-liberal (GLP) voters" -9 "Green (GPS) voters", labcol(gs0)) xlab(, labcol(gs6) format(%3.2f)) ///
	xtitle("                                                                     Party leader choice probability (marginal means)", col(gs6) size(*0.7)) ysize(2.05) ///
	name(byparty_cultcon, replace)
	
*------------------------------------------------------------------------------------------------*
**# Figure F1: Marginal effect of beer attribute (AMCE), by party and candidate's class origin ***
*------------------------------------------------------------------------------------------------*
	
use SYMBREP_FINAL, clear

reg CHOICE_DV i.ATTR_GENDER i.ATTR_EDUCATION i.ATTR_ECONPOS i.ATTR_CULTPOS i.ATTR_ORIGIN##i.ATTR_CULTCON, vce(cluster record)
	testparm  ATTR_ORIGIN#ATTR_CULTCON
	*margins, dydx(3.ATTR_CULTCON) at(ATTR_ORIGIN=(1 2 3))
	
cap postclose results_party
postfile results_party ATTR_ORIGIN b LB95 UB95 y str50 ylab using results_party, replace
foreach attorigin of numlist 1 2 3 {
	
reg CHOICE_DV i.ATTR_GENDER i.ATTR_EDUCATION i.ATTR_ECONPOS i.ATTR_CULTPOS i.ATTR_ORIGIN##i.ATTR_CULTCON, vce(cluster record)
	margins, dydx(3.ATTR_CULTCON) at(ATTR_ORIGIN=(`attorigin'))
		post results_party (`attorigin') (r(table)[1,2]) (r(table)[5,2]) (r(table)[6,2]) (1.5) ("Overall")

reg CHOICE_DV i.ATTR_GENDER##i.PARTY i.ATTR_EDUCATION##i.PARTY i.ATTR_ECONPOS##i.PARTY i.ATTR_CULTPOS##i.PARTY i.ATTR_ORIGIN##i.ATTR_CULTCON##i.PARTY, vce(cluster record)
	margins, dydx(3.ATTR_CULTCON) at(ATTR_ORIGIN=(`attorigin') PARTY=(1))
		post results_party (`attorigin') (r(table)[1,2]) (r(table)[5,2]) (r(table)[6,2]) (4) ("Radical right (SVP)")
	margins, dydx(3.ATTR_CULTCON) at(ATTR_ORIGIN=(`attorigin') PARTY=(3))
		post results_party (`attorigin') (r(table)[1,2]) (r(table)[5,2]) (r(table)[6,2]) (5) ("Center-right / liberals (FDP)")
	margins, dydx(3.ATTR_CULTCON) at(ATTR_ORIGIN=(`attorigin') PARTY=(5))
		post results_party (`attorigin') (r(table)[1,2]) (r(table)[5,2]) (r(table)[6,2]) (6) ("Center-right / Christian democrats (CVP)")
	margins, dydx(3.ATTR_CULTCON) at(ATTR_ORIGIN=(`attorigin') PARTY=(2))
		post results_party (`attorigin') (r(table)[1,2]) (r(table)[5,2]) (r(table)[6,2]) (7) ("Center-left / social democrats (SP)")
	margins, dydx(3.ATTR_CULTCON) at(ATTR_ORIGIN=(`attorigin') PARTY=(6))
		post results_party (`attorigin') (r(table)[1,2]) (r(table)[5,2]) (r(table)[6,2]) (8) ("Green-liberals (GLP)")
	margins, dydx(3.ATTR_CULTCON) at(ATTR_ORIGIN=(`attorigin') PARTY=(4))
		post results_party (`attorigin') (r(table)[1,2]) (r(table)[5,2]) (r(table)[6,2]) (9) ("Greens (GPS)")
	
}		
		
postclose results_party
use results_party, clear
	replace y = -y
	lab def ATTR_ORIGIN 1 `""Candidate from""upper-class origin" "(wealthy family)""' 2 `""Candidate from" "middle-class origin" "(teacher family)""' 3 `""Candidate from" "working-class origin" "(working-class family)""'
	lab val ATTR_ORIGIN ATTR_ORIGIN
grstyle set color gs0 gs0	

twoway scatter y b, subtitle(,size(*0.75)) || rcap LB95 UB95 y, horizontal by(ATTR_ORIGIN, note("") legend(off) scale(*1.5) row(1) imargin(*2) ///
	title("                                                             Candidate enjoys going to drink a beer in favourite pub" ///
		"                                                             (working-class cultural consumption)" " " ///
		"{it:                                                             [Reference group: Candidate enjoys listening to classical music}" ///
		"{it:                                                             with a glass of wine (upper-class cultural consumption)]}" " ", size(*0.6)) ) ///
	xline(0, lcol(gs6) lpattern(solid)) ///
	yscale(range(0 -9.5)) ytitle("", col(gs6) size(*0.8)) ylab(-1.5 "Overall (all voters)" -4 "Radical right (SVP) voters" -5 "Center-right / liberals (FDP) voters" ///
	-6 "Center-right / Christian dem. (CVP) voters" -7 "Center-left / social democratic (SP) voters" ///
	-8 "Green-liberal (GLP) voters" -9 "Green (GPS) voters", labcol(gs0)) xlab(, labcol(gs6) format(%3.1f)) ///
	xtitle("                                                                         Party leader choice probability (AMCE)", col(gs6) size(*0.7)) xsize(7) ///
	name(byparty_origin, replace)
	
*----------------------------------------------------------------*
**# Appendix G: Socioeconomic composition of party electorates ***
*----------------------------------------------------------------*
	
use SYMBREP_FINAL, clear

reg TERTIARY i.PARTY
margins PARTY, post
coefplot, col(gs0) ciopts(col(gs0)) /// 
	order(1.PARTY 3.PARTY 2.PARTY) ///
	coeflab(1.PARTY = "Radical right (SVP)" 3.PARTY = "Center-right / liberals (FDP)" ///
	5.PARTY = "Center-right / Christian democrats (Mitte)" 2.PARTY = "Center-left / social democrats (SP)" ///
	6.PARTY = "Green-liberals (GLP)" 4.PARTY = "Greens (GPS)") ///
	ylab(, labcol(gs0)) xlab(0(0.1)0.5, format(%3.2f) labcol(gs3)) yscale(range(0.1 6.9)) ///
	xsize(8) scale(*1.5)
	
gen worker = (OESCH == 5) if !mi(OESCH)
reg worker i.PARTY
margins PARTY, post
coefplot, col(gs0) ciopts(col(gs0)) /// 
	order(1.PARTY 3.PARTY 2.PARTY) ///
	coeflab(1.PARTY = "Radical right (SVP)" 3.PARTY = "Center-right / liberals (FDP)" ///
	5.PARTY = "Center-right / Christian democrats (Mitte)" 2.PARTY = "Center-left / social democrats (SP)" ///
	6.PARTY = "Green-liberals (GLP)" 4.PARTY = "Greens (GPS)") ///
	ylab(, labcol(gs0)) xlab(0(0.1)0.4, format(%3.2f) labcol(gs3)) yscale(range(0.1 6.9)) ///
	xsize(8) scale(*1.5)

reg HINC10 i.PARTY
margins PARTY, post
coefplot, col(gs0) ciopts(col(gs0)) /// 
	order(1.PARTY 3.PARTY 2.PARTY) ///
	coeflab(1.PARTY = "Radical right (SVP)" 3.PARTY = "Center-right / liberals (FDP)" ///
	5.PARTY = "Center-right / Christian democrats (Mitte)" 2.PARTY = "Center-left / social democrats (SP)" ///
	6.PARTY = "Green-liberals (GLP)" 4.PARTY = "Greens (GPS)") ///
	ylab(, labcol(gs0)) xlab(, format(%3.1f) labcol(gs3)) yscale(range(0.1 6.9)) ///
	xsize(8) scale(*1.5)

reg SSS i.PARTY
margins PARTY, post
coefplot, col(gs0) ciopts(col(gs0)) /// 
	order(1.PARTY 3.PARTY 2.PARTY) ///
	coeflab(1.PARTY = "Radical right (SVP)" 3.PARTY = "Center-right / liberals (FDP)" ///
	5.PARTY = "Center-right / Christian democrats (Mitte)" 2.PARTY = "Center-left / social democrats (SP)" ///
	6.PARTY = "Green-liberals (GLP)" 4.PARTY = "Greens (GPS)") ///
	ylab(, labcol(gs0)) xlab(, format(%3.1f) labcol(gs3)) yscale(range(0.1 6.9)) ///
	xsize(8) scale(*1.5)

gen work_origin = (CLASS3_PARENTS_MAX == 1)
reg work_origin i.PARTY
margins PARTY, post
coefplot, col(gs0) ciopts(col(gs0)) /// 
	order(1.PARTY 3.PARTY 2.PARTY) ///
	coeflab(1.PARTY = "Radical right (SVP)" 3.PARTY = "Center-right / liberals (FDP)" ///
	5.PARTY = "Center-right / Christian democrats (Mitte)" 2.PARTY = "Center-left / social democrats (SP)" ///
	6.PARTY = "Green-liberals (GLP)" 4.PARTY = "Greens (GPS)") ///
	ylab(, labcol(gs0)) xlab(, format(%3.2f) labcol(gs3)) yscale(range(0.1 6.9)) ///
	xsize(8) scale(*1.5)

reg WOMAN i.PARTY
margins PARTY, post
coefplot, col(gs0) ciopts(col(gs0)) /// 
	order(1.PARTY 3.PARTY 2.PARTY) ///
	coeflab(1.PARTY = "Radical right (SVP)" 3.PARTY = "Center-right / liberals (FDP)" ///
	5.PARTY = "Center-right / Christian democrats (Mitte)" 2.PARTY = "Center-left / social democrats (SP)" ///
	6.PARTY = "Green-liberals (GLP)" 4.PARTY = "Greens (GPS)") ///
	ylab(, labcol(gs0)) xlab(0.3(0.1)0.7, format(%3.2f) labcol(gs3)) yscale(range(0.1 6.9)) ///
	xsize(8) scale(*1.5)
	
*----------------------------------------------------------------*
**# Figure H1: Socioeconomic composition of party electorates ***
*----------------------------------------------------------------*
	
use SYMBREP_FINAL, clear
cap postclose results_party_imm
postfile results_party_imm IMM b LB95 UB95 y str50 ylab using results_party_imm, replace

gen antiimm = (inrange(IMM, 0, 5)) if !mi(IMM)
tab antiimm SVP, cell

foreach antiimm of numlist 0 1 {
preserve
keep if antiimm == `antiimm'
reg CHOICE_DV i.ATTR_GENDER i.ATTR_EDUCATION i.ATTR_ECONPOS i.ATTR_CULTPOS i.ATTR_ORIGIN i.ATTR_CULTCON, vce(cluster record)
	margins, at(ATTR_CULTCON=(3))
		post results_party_imm (`antiimm') (r(table)[1,1]) (r(table)[5,1]) (r(table)[6,1]) (1.5) ("Overall")
reg CHOICE_DV i.ATTR_GENDER##i.SVP i.ATTR_EDUCATION##i.SVP i.ATTR_ECONPOS##i.SVP i.ATTR_CULTPOS##i.SVP i.ATTR_ORIGIN##i.SVP i.ATTR_CULTCON##i.SVP, vce(cluster record)
	margins, at(ATTR_CULTCON=(3) SVP=(1))
		post results_party_imm (`antiimm') (r(table)[1,1]) (r(table)[5,1]) (r(table)[6,1]) (4) ("Radical right (SVP)")
	margins, at(ATTR_CULTCON=(3) SVP=(0))
		post results_party_imm (`antiimm') (r(table)[1,1]) (r(table)[5,1]) (r(table)[6,1]) (5) ("Non-SVP")
restore
}		
postclose results_party_imm
use results_party_imm, clear
	replace y = -y
	lab def IMM 0 `""Subsample:" "Pro-immigration voters""' 1 `""Subsample:" "Anti-immigration voters""'
	lab val IMM IMM

twoway scatter y b, subtitle(,size(*0.8)) || rcap LB95 UB95 y, horizontal by(IMM, note("") legend(off)  scale(*1.8) imargin(*8)) ///
	yscale(range(0 -6)) yline(0 -3, lcol(gs12)) xline(0.5, lcol(gs6) lpattern(solid)) ///
	ytitle("") ylab(-1.5 "Overall (all voters)" -4 "Radical right (SVP) voters" -5 "Non-SVP voters", labcol(gs0)) xlab(, labcol(gs6) format(%3.2f)) ///
	xtitle("                                                                     Party leader choice probability (marginal means)", col(gs6) size(*0.75)) ysize(3)
	
	
	
	
	
	